import type { AddressItem, AddressParams } from '@/types/address'
import { http } from '@/utils/http'

/* 会员中心-地址管理
添加收货地址 */
export const addmemberAddressAPI = (data: AddressParams) => {
  return http<{ id: string | number }>({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

/* 会员中心-地址管理
获取收货地址列表 */
export const getMemberAddressAPI = () => {
  return http<AddressItem[]>({
    url: '/member/address',
    method: 'GET',
  })
}

/* 会员中心-地址管理
获取收货地址详情 */
export const getAddressDetailAPI = (id: string) => {
  return http<AddressItem>({
    url: `/member/address/${id}`,
    method: 'GET',
  })
}
/* 会员中心-地址管理
修改收货地址 */
export const putMemberAddressAPI = (id: string, data: AddressParams) => {
  return http<{ id: string | number }>({
    url: `/member/address/${id}`,
    method: 'PUT',
    data,
  })
}
/* 会员中心-地址管理
删除收货地址 */
export const delMemberAddressAPI = (id: string) => {
  return http<{ id: string }>({
    url: `/member/address/${id}`,
    method: 'DELETE',
  })
}
